package com.cy.pj.sys.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.sys.pojo.SysGoods;
import com.cy.pj.sys.pojo.SysGoodsType;
import com.cy.pj.sys.pojo.SysUser;
import com.cy.pj.sys.pojo.SysUserDept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SysGoodsDao extends BaseMapper<SysGoods> {

    //使用了PageHelper以后,只需要写如下方法即可
    List<SysGoods> findPageObjects(String goodsname);

    @Update("update sys_goods set state=#{valid},modifiedTime=now() where id=#{id}")
    int validById(Long id, Integer valid);

    int saveObject(SysGoods goods);

    @Select("select * from sys_goods where id=#{id}")
    SysGoods findObjectById(Long id);

    @Update("update sys_goods set name=#{name},original_price=#{originalPrice},price=#{price},addr=#{addr},modifiedTime=#{modifiedTime},goods_type_id=#{goodsTypeId},state=#{state} where id=#{id}")
    int updateObject(SysGoods goods);

    @Delete("DELETE FROM sys_goods WHERE id=#{id}")
    void deleteById(Long id);
}
